#!/usr/bin/env python
#-*-coding:utf-8-*- 
__author__ = 'Mzx'

from __init__ import db,app
from flask import render_template
from models import region_retailsales,shop_level
from sqlalchemy import desc


@app.route('/demo1')
def echarstime_demo1():
    k = region_retailsales.query.order_by(desc(region_retailsales._retailSales)).all()
    local = {}
    for i in k:
        local[i._region] = i._retailSales

    print(local)
    return render_template('test1.html',local=local)

@app.route('/demo2')
def line_demo2():
    k = shop_level.query.all()
    mytmp = dict()
    mylist = ['一星', '二星', '三星', '四星', '五星']
    for i in k:
        mytmp[i._year] = [i._level1,i._level2,i._level3,i._level4,i._level5]
    print(mytmp)
    print(mylist)
    return render_template('test2.html',mytmp = mytmp,mylist=mylist)


if __name__ == '__main__':
    app.run()